﻿namespace AC.ExtendedRenderer.Toolkit
{
    using AC.ExtendedRenderer.Toolkit.Utils;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;
    using System.Windows.Forms.Design;

    [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip | ToolStripItemDesignerAvailability.ToolStrip), DefaultEvent("ValueChanged")]
    public class KryptonViewBar : ToolStripControlHostFixed
    {
        private IContainer components;

        public event EventHandler KcmdleftClick;

        public event EventHandler KcmdmiddleleftClick;

        public event EventHandler KcmdmiddlerightClick;

        public event EventHandler KcmdrightClick;

        public KryptonViewBar() : base(new KryptonViewButtons())
        {
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
        }

        private void OnKcmdLeftClick(object Sender, EventArgs e)
        {
            if (this.KcmdleftClick != null)
            {
                this.KcmdleftClick(Sender, e);
            }
        }

        private void OnKcmdMiddleLeftClick(object Sender, EventArgs e)
        {
            if (this.KcmdmiddleleftClick != null)
            {
                this.KcmdmiddleleftClick(Sender, e);
            }
        }

        private void OnKcmdMiddleRightClick(object Sender, EventArgs e)
        {
            if (this.KcmdmiddlerightClick != null)
            {
                this.KcmdmiddlerightClick(Sender, e);
            }
        }

        private void OnKcmdRightClick(object Sender, EventArgs e)
        {
            if (this.KcmdrightClick != null)
            {
                this.KcmdrightClick(Sender, e);
            }
        }

        protected override void OnSubscribeControlEvents(Control c)
        {
            base.OnSubscribeControlEvents(c);
            (base.Control as KryptonViewButtons).kcmdleft.Click += new System.EventHandler(this.OnKcmdLeftClick);
            (base.Control as KryptonViewButtons).kcmdmiddleleft.Click += new System.EventHandler(this.OnKcmdMiddleLeftClick);
            (base.Control as KryptonViewButtons).kcmdmiddleright.Click += new System.EventHandler(this.OnKcmdMiddleRightClick);
            (base.Control as KryptonViewButtons).kcmdright.Click += new System.EventHandler(this.OnKcmdRightClick);
        }

        protected override void OnUnsubscribeControlEvents(Control c)
        {
            base.OnUnsubscribeControlEvents(c);
            (base.Control as KryptonViewButtons).kcmdleft.Click -= new System.EventHandler(this.OnKcmdLeftClick);
            (base.Control as KryptonViewButtons).kcmdmiddleleft.Click -= new System.EventHandler(this.OnKcmdMiddleLeftClick);
            (base.Control as KryptonViewButtons).kcmdmiddleright.Click -= new System.EventHandler(this.OnKcmdMiddleRightClick);
            (base.Control as KryptonViewButtons).kcmdright.Click -= new System.EventHandler(this.OnKcmdRightClick);
        }

        [DefaultValue(typeof(string), "100%"), Category("ViewButtons")]
        public string PercentageLabel
        {
            get
            {
                return (base.Control as KryptonViewButtons).PercentageLabel;
            }
            set
            {
                (base.Control as KryptonViewButtons).PercentageLabel = value;
            }
        }

        [Category("ViewButtons"), DefaultValue(typeof(Size), "140, 16")]
        public Size ViewBarSize
        {
            get
            {
                return (base.Control as KryptonViewButtons).Size;
            }
            set
            {
                (base.Control as KryptonViewButtons).Size = value;
            }
        }

        [Category("Control")]
        public KryptonViewButtons ViewButtons
        {
            get
            {
                return (base.Control as KryptonViewButtons);
            }
        }

        public delegate void EventHandler(object Sender, EventArgs e);
    }
}

